package com.winchain.chainbill.bill.base.service.impl;

import com.shell.bee.base.utils.SystemUtil;
import com.shell.bee.persistence.service.impl.PersistentServiceImpl;
import com.winchain.chainbill.bill.base.dao.CbDctDao;
import com.winchain.chainbill.bill.base.po.CbDct;
import com.winchain.chainbill.bill.base.po.CbDctDats;
import com.winchain.chainbill.bill.base.service.CbDctDatsService;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class CbDctDatsServiceImpl extends PersistentServiceImpl<CbDctDats> implements CbDctDatsService {
	@Autowired
	private CbDctDao cbDctDao;

	public boolean calDayTotalAmt(String workDate) {
		List<CbDct> cbDctList = this.cbDctDao.selectDctsByDate(workDate);
		for (CbDct dct : cbDctList) {
			CbDctDats cbDctDats = new CbDctDats();
			cbDctDats.setDatsId(SystemUtil.getUUID());
			cbDctDats.setFinId(dct.getFinId());
			cbDctDats.setDatsDate(workDate);
			cbDctDats.setDatsMonth(workDate.substring(0, 6));
			cbDctDats.setTotalAmt(dct.getDctAmt());
			save(cbDctDats);
		}
		return true;
	}
}
